import Vue from 'vue'
import Router from 'vue-router'
// import HelloWorld from '@/components/HelloWorld'
// import Login from '@/views/Login';
// import Register from '@/views/Register';
// import Index from '@/views/Index';
// import Home from '@/views/Home';
// import Friends from '@/views/Friends';
// import Search from '@/views/Search';
// import Setting from '@/views/Setting';
// import Detail from '@/views/Detail';
Vue.use(Router)

// 路由懒加载--当访问到某一个URL的时候,再去请求该组件

var router = new Router({

	routes: [{
			path: '/',
			redirect: '/yindao',
			name: 'HelloWorld',
			component: () => import('@/components/HelloWorld')
		},
		{
			path: '/yindao',
			name: 'yindao',
			component: () => import('@/views/Yindao'),
			meta: {
				title: '引导页'
			}
		},
		{
			path: '/login',
			name: 'login',
			component: () => import('@/views/Login'),
			meta: {
				title: '登录'
			}
		},
		{
			path: '/messLogin',
			name: 'messLogin',
			component: () => import('@/views/MessLogin'),
			meta: {
				title: '短信登录'
			}
		},
		{
			path: '/register',
			name: 'register',
			component: () => import('@/views/Register'),
			meta: {
				title: '注册'
			}
		},
		{
			path: '/index',
			redirect: '/home',
			name: 'index',
			component: () => import('@/views/Index'),
			children: [{
					path: '/home',
					name: 'home',
					component: () => import('@/views/Home'),
					meta: {
						title: '首页'
					}
				},
				{
					path: '/mendian',
					name: 'mendian',
					component: () => import('@/views/Mendian'),
					meta: {
						title: '门店'
					},
				},
				{
					path: '/mddetail',
					name: 'mddetail',
					component: () => import('@/views/MdDetail'),
					meta: {
						title: '门店详情'
					},
				},
				{
					path: '/quan',
					name: 'quan',
					component: () => import('@/views/Quan'),
					meta: {
						title: '甜甜圈'
					}
				},
				{
					path: '/my',
					name: 'my',
					component: () => import('@/views/My'),
					meta: {
						title: '我的'
					}
				},
				{
					path: '/cart',
					name: 'cart',
					// redirect:'/login',
					component: () => import('@/views/Cart'),
					meta: {
						title: '购物车'
					}
				}
			]
		},
		{
			path: '/detail/:id',
			name: 'detail',
			component: () => import('@/views/Detail'),
			meta: {
				title: '商品详情'
			}
		},
		{
			path: '/fenlei',
			name: 'fenlei',
			component: () => import('@/views/Fenlei'),
			meta: {
				title: '分类'
			}
		},
		{
			path: '/managementAddress',
			name: 'managementAddress',
			component: () => import('@/views/ManagementAddress'),
			meta: {
				title: '管理收货地址'
			}
		},
		{
			path: '/addAddress',
			name: 'addAddress',
			component: () => import('@/views/AddAddress'),
			meta: {
				title: '新增收货地址'
			}
		},
		{
			path: '/set',
			name: 'set',
			component: () => import('@/views/Set'),
			meta: {
				title: '设置'
			}
		},
		{
			path: '/information',
			name: 'information',
			component: () => import('@/views/Information'),
			meta: {
				title: '个人资料'
			}
		},
		{
			path: '/phone',
			name: 'phone',
			component: () => import('@/views/Phone'),
			meta: {
				title: '验证手机号'
			}
		},
		{
			path: '/paymentCode',
			name: 'paymentCode',
			component: () => import('@/views/PaymentCode'),
			meta: {
				title: '支付密码设置'
			}
		},
		{
			path: '/loginPassword',
			name: 'loginPassword',
			component: () => import('@/views/LoginPassword'),
			meta: {
				title: '登录密码设置'
			}
		},
		{
			path: '/about',
			name: 'about',
			component: () => import('@/views/About'),
			meta: {
				title: '关于五色糖'
			}
		},
		{
			path: '/tongzhi',
			name: 'tongzhi',
			component: () => import('@/views/Tongzhi'),
			meta: {
				title: '通知'
			}
		},
		{
			path: '/message',
			name: 'message',
			component: () => import('@/views/Message'),
			meta: {
				title: '甜甜圈消息'
			}
		},
		{
			path: '/official',
			name: 'official',
			component: () => import('@/views/Official'),
			meta: {
				title: '五色糖官方'
			}
		},
		{
			path: '/inform',
			name: 'inform',
			component: () => import('@/views/Inform'),
			meta: {
				title: '通知消息'
			}
		},
		{
			path: '/conversation',
			name: 'conversation',
			component: () => import('@/views/Conversation'),
			meta: {
				title: '私信'
			}
		},
		{
			path: '/blacklist',
			name: 'blacklist',
			component: () => import('@/views/Blacklist'),
			meta: {
				title: '黑名单'
			}
		},
		{
			path: '/attention',
			name: 'attention',
			component: () => import('@/views/Attention'),
			meta: {
				title: '我的关注'
			}
		},
		{
			path: '/collect',
			name: 'collect',
			component: () => import('@/views/Collect'),
			meta: {
				title: '我的收藏'
			}
		},
		{
			path: '/myOrder',
			name: 'myOrder',
			component: () => import('@/views/MyOrder'),
			meta: {
				title: '我的订单'
			}
		},
		{
			path: '/discountCoupon',
			name: 'discountCoupon',
			component: () => import('@/views/DiscountCoupon'),
			meta: {
				title: '优惠券'
			}
		},
		{
			path: '/history',
			name: 'history',
			component: () => import('@/views/History'),
			meta: {
				title: '我的足迹'
			}
		},
		{
			path: '/groupBuying',
			name: 'groupBuying',
			component: () => import('@/views/GroupBuying'),
			meta: {
				title: '我的团购'
			}
		},
		{
			path: '/intro',
			name: 'intro',
			component: () => import('@/views/Intro'),
			meta: {
				title: '五色糖简介'
			}
		},
		{
			path: '/protection',
			name: 'protection',
			component: () => import('@/views/Protection'),
			meta: {
				title: '隐私权政策'
			}
		},
		{
			path: '/fashion',
			name: 'fashion',
			component: () => import('@/views/Fashion'),
			meta: {
				title: '五色糖潮品'
			}
		},
		{
			path: '/settlement',
			name: 'settlement',
			component: () => import('@/views/Settlement'),
			meta: {
				title: '提交订单'
			}
		},
		{
			path: '/addressPlace',
			name: 'addressPlace',
			component: () => import('@/views/AddressPlace'),
			meta: {
				title: '收货地址'
			}
		},
		{
			path: '/newAddress',
			name: 'newAddress',
			component: () => import('@/views/NewAddress'),
			meta: {
				title: '新增地址'
			}
		},
		{
			path: '/payfor',
			name: 'payfor',
			component: () => import('@/views/Payfor'),
			meta: {
				title: '支付'
			}
		},
		{
			path: '/payment',
			name: 'payment',
			component: () => import('@/views/Payment'),
			meta: {
				title: '支付'
			}
		},
		{
			path: '/search',
			name: 'search',
			component: () => import('@/views/Search'),
			meta: {
				title: '搜索'
			}
		},
	]
})

router.beforeEach((to, from, next) => {
	if (to.meta.title) {
		document.title = to.meta.title
	}
	next()
})


export default router;
